<template>
    <div class="right-slider-area" @mouseenter="showSlider = true" @mouseleave="showSlider = false">
        <transition name="el-fade-in">
            <div v-show="showSlider" class="slider-wrapper">
                <el-slider v-model="value" vertical height="200px" :show-tooltip="true" class="transparent-slider" />
            </div>
        </transition>
    </div>
</template>

<script setup lang="ts">
import { ref, watchEffect, inject } from "vue";

//获取自定义全局方法
const { authStore } = inject<any>("method");

//组件的双向数据绑定
const value = defineModel({ type: Number, default: 10 });

//监听value的变化，并更新背景透明度
watchEffect(() => {
    authStore.setHomeBackgroundOpacity(value.value)
});

const showSlider = ref(false);
</script>

<style scoped lang="less">
.main-content {
    width: calc(100% - 20px); /* 留出右侧空间 */
    height: 100%;
    padding: 20px;
}

.right-slider-area {
    position: fixed;
    right: 0;
    top: 60px;
    bottom: calc(100vh - 60px - 223.5px);
    width: 40px; /* 鼠标悬停区域宽度 */
    z-index: 100;
}

.slider-wrapper {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    padding: 20px 10px;
    background-color: rgba(255, 255, 255, 0);
    backdrop-filter: blur(5px);
    border-radius: 10px 0 0 10px;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
}

/* 透明滑块样式 */
.transparent-slider {
    --el-slider-main-bg-color: rgba(255, 255, 255, 0.1);
    --el-slider-runway-bg-color: transparent;
    --el-slider-button-hover-color: var(--el-color-primary);
    --el-slider-stop-bg-color: var(--el-color-white);
}

.transparent-slider :deep(.el-slider__button) {
    border: 2px solid var(--el-color-primary);
    background-color: var(--el-color-primary);
}

.transparent-slider :deep(.el-slider__bar) {
    background-color: var(--el-color-primary);
}
</style>
